/**
 * @title: NacosConfig
 * @projectName mscloud
 * @Description TODO
 * @Author
 * @Date 2022/3/3 20:17
 */
package com.atguigu.springcloud.cloudsentinelgatewaydevelop.config;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingMaintainService;
import com.alibaba.nacos.api.naming.NamingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.Properties;
@EnableConfigurationProperties({
        NacosServicePorperties.class,
        NacosConfigPorperties.class
})
@Configuration
public class NacosConfig {
    @Autowired
    NacosServicePorperties nacosServicePorperties;

    @Bean
    public NamingMaintainService getNamingMaintainService() throws NacosException {
        return NacosFactory.createMaintainService(nacosServicePorperties.getServerAddr());
    }
    @Bean
    public ConfigService getConfigService() throws NacosException {
        return NacosFactory.createConfigService(nacosServicePorperties.getServerAddr());
    }

    @Bean
    public NamingService getNamingService() throws NacosException {
        return NacosFactory.createNamingService(nacosServicePorperties.getServerAddr());
    }

}
